package com.my.jli.util;

import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Data
public class PageUtil implements Serializable {
    private static final long serialVersionUID = 1L;
    private int total;
    private int current;
    private int totalPage;
    private List<?> list;
    private Map<?, ?> map;

    public PageUtil(List<?> list, Long total, int current) {
        this.list = list;
        this.total = total.intValue();
        this.current = current;
    }

    public PageUtil(Map<?, ?> map, Long total, int current) {
        this.map = map;
        this.total = total.intValue();
        this.current = current;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int size) {
        this.totalPage = (int) Math.ceil((double) total / size);
    }
}
